export default {
	namespaced: true,
	
	state:{
		status:false,												 //tim状态
		msg:null,												     //tim消息
		noread:{}												     //tim消息未读
	},
	
	mutations: {
		// 设置-tim状态
		["SET_timStatus"] (state, payload) { 
			state.status = payload;
		},
		// 设置-tim消息
		["SET_timMsg"] (state, payload) { 
			state.msg = payload;
		},
		// 设置-tim消息未读
		["SET_timNoread"] (state, payload) { 
			let noread = JSON.parse(JSON.stringify(state.noread));
			if(payload.account){
				if(payload.value){
					noread[payload.account] = noread[payload.account]?noread[payload.account]+1 : 1;
				}else{
					delete noread[payload.account]
				}
				uni.setStorageSync('timNoread', noread);
				state.noread = noread;
			}
		}
	}
}